Skip to content

ConnectableObservableAsync.ConnectAsync(CancellationToken) method

Defined in

Type: ConnectableObservableAsync Namespace: ReactiveUI.Extensions.Async Assembly: ReactiveUI.Extensions.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

public abstract ValueTask<IAsyncDisposable> ConnectAsync(CancellationToken cancellationToken)

Summary: Asynchronously establishes a connection to the target resource and returns a disposable handle for managing the connection's lifetime.

Parameters

NameTypeDescription
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the asynchronous connection operation.

Returns: ValueTask -- A value task that represents the asynchronous operation. The result contains an IAsyncDisposable that should be disposed to close the connection.

Remarks

The returned IAsyncDisposable must be disposed when the connection is no longer needed to ensure proper resource cleanup. Multiple calls to this method may result in multiple independent connections, depending on the implementation.